import requests
import json
import csv
import time

# ip = 'http://zqdr-api.lwfjmj.com/v2/check_point/play?api_token=RLAtZGW3nFugAPnipSicZ8UmZCfqWkHe&is_time_out=0&timestamp=1592380047451&user_id=6379111&sign=cff0f2afaf623284c330bc8618fa3b60'
ip = 'http://m.beauty-story.cn/api/paper/'
headers ={
    'User-Agent':'Dalvik/2.1.0 (Linux; U; Android 8.0.0; AUM-AL00 Build/HONORAUM-AL00)',
    'Host':'zqdr-api.lwfjmj.com'
}

def crol_question():

    content = requests.get(ip,headers=headers)
    print(content.json())
    title = content.json().get('data')['question_info']['title']
    subtitle = content.json().get('data')['question_info']['subtitle']
    type = content.json().get('data')['question_info']['type']
    content = content.json().get('data')['question_info']['content']
    print(title)
    sub = (title,subtitle,type,content)
    rows = []
    rows.append(sub)
    return rows


for i in range(200):
    with open('1.csv','a+') as f :
        f_csv = csv.writer(f)
        aa = ['title','subtitle','type','content']
        f_csv.writerow(aa)
        writer = f_csv.writerows(crol_question())
        time.sleep(1)